//
//  OverviewAreaAccountView.swift
//  KoiAccounting
//
//  Created by 纪洪文 on 22.03.25.
//

import SwiftUI

struct OverviewAreaAccountingView: View {
    
    @State var expenseMode = true
    
    var itemData:OverviewAreaAccountingData
    
    var body: some View {
        HStack (spacing:0){
            VStack (alignment: .leading, spacing: 0){
                Button (action: { expenseMode.toggle() }) {
                    HStack {
                        Text(expenseMode ? "月支出" : "月收入")
                            .font(.system(size: 14))
                            .fontWeight(.semibold)
                            .foregroundColor(Color.koiColorPrimary)
                        Image("koi_ic_arrow_switch").resizable().frame(width: 16, height: 16)
                    }
                    .padding(EdgeInsets(top: 0, leading: 0, bottom: 2, trailing: 0 ))
                }

                HStack {
                    Text(expenseMode ? itemData.getExpenseAmount() : itemData.getIncomeAmount())
                        .font(.system(size:34))
                        .bold()
                        .foregroundColor(Color.koiColorTitle)
                }
            }
            Spacer()
            VStack (alignment:.trailing, spacing: 5){
                Text("月结余")
                    .font(.system(size: 14))
                    .foregroundColor(Color.koiColorTitleSecond)
                Text(itemData.getBalanceAmount())
                    .font(.system(size: 14))
                    .foregroundColor(Color.koiColorTitleSecond)
            }
        }
        .padding(16)
        .background(Color.koiColorBackgroundItem)
        .cornerRadius(16)
    }
}

#Preview {
    OverviewAreaAccountingView(itemData:OverviewAreaAccountingData())
}
